package 尚硅谷juc大厂.test2;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test2 {

    /**
     * CompletableFuture不指定线程池，则默认使用ForkJoinPool
     */
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 2L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(50));
        CompletableFuture<Void> futer = CompletableFuture.runAsync(() -> {
            //打印出：ForkJoinPool.commonPool-worker-1
            System.out.println(Thread.currentThread().getName());
        });
        CompletableFuture.runAsync(()->{
            //打印出：pool-1-thread-1
            System.out.println(Thread.currentThread().getName());
        },executor);
        //线程池使用完要关闭
        executor.shutdown();
    }
}
